package operation;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOperation implements IOperation{
    public void work(BookList bookList){
        Scanner sc=new Scanner(System.in);
        System.out.println("查找图书");
        System.out.println("输入要查找的图书名:");
        String name=sc.nextLine();
        int size= bookList.getUsedsize();
        int i=0;
        for(i=0;i<size;i++){
            Book book=bookList.getBook(i);
            if(book.getName().equals(name)){
                System.out.println(book);
                return;
            }
            if(i>=size){
                System.out.println("没有这本书!");
                return;
            }
    }
}}
